<?php !defined("IN_SYSTEM") && exit("ACCESS DENY");?>
{template ../default/header}
{template top}
<div id="uc">
{template uc/left}
<div id="uc_main">
	<div class="uc_tab">
			<ul>
			<li><span><a{if !isset($_GET['f'])} class="on"{/if} href="{url home.php?m=addr}">收货地址</a></span></li>
			<li><span><a{if $_GET['f'] == 'new'} class="on"{/if} href="{url home.php?m=addr&f=add}">新增收货地址</a></span></li>
			</ul>
		</div>
		<div id="uc_contain">
		{if !$_GET['f']}
		{loop $datas $v}
		<table  width="100%" class="uc_tableb mb10">
		<tbody><tr><th align="left"><span class="fr"><a href="{url home.php?m=addr&f=edit&id=$v[id]}">编辑</a></span><strong>收货地址{echo ++$i}</strong></th></tr>
		<tr><td >收货人：&nbsp;&nbsp;{$v['firstname']} {$v['lastname']}<br>
					详细地址：&nbsp;&nbsp;{$v['street1']} {$v['street']}<br>
					手机号码：&nbsp;&nbsp;{$v['phone']}<br>
					固定电话：&nbsp;&nbsp;{$v['tel']}<br>
					电子邮件：&nbsp;&nbsp;{$v['email']}<br>
					邮政编码：&nbsp;&nbsp;{$v['zip']}</td></tr>
		</tbody>
		</table>
		{/loop}
		{/if}
			
		{if $_GET['f'] == 'add' || $_GET['f'] == 'edit'}
			<form action="{url home.php?m=addr}" method="POST" class="uc_search">
			<input type="hidden" value="{$id}" name="id"/>
			<input type="hidden" value="save" name="f"/>
			<input type="hidden" name="street1" value="{$result['street1']}" id="street1"/>
			<input type="hidden" id="rid" value="{$id}" name="rid" class="searchid"/>
			<input type="hidden" value="true" name="addrsubmit"/>
			<table cellspacing="0" class="uc_fa_table">
			<tr><td class="td1">收货人：</td><td colspan="3"><input type="text" name="firstname" class="input" size="32" value="{$result['firstname']}" /></td></tr>
			<tr><td class="td1">所在地区：</td><td colspan="3">{$region}</td></tr>
			<tr><td class="td1">详细地址：</td><td colspan="3"><span id="address"></span><input type="text" name="street" class="input" size="32" value="{$result['street']}" /></td></tr>
			<tr><td class="td1">手机号码：</td><td colspan="3"><input type="text" name="phone" class="input" size="32" value="{$result['phone']}" /></td></tr>
			<tr><td class="td1">固定电话：</td><td colspan="3"><input type="text" name="tel" class="input" size="32" value="{$result['tel']}" /></td></tr>
			<tr><td class="td1">电子邮箱：</td><td colspan="3"><input type="text" name="email" class="input" size="32" value="{$result['email']}" /></td></tr>
			<tr><td class="td1">邮政编码：</td><td colspan="3"><input type="text" name="zip" class="input" size="32" value="{$result['zip']}" /></td></tr>
			<tr class="bg2"><td class="td1"></td><td colspan="3"><input type="submit" class="button" value="保存" /> </td></tr>
			</table>
			</form>
			<script type="text/javascript">
			function region(obj,le){
				var val=$(obj).val();
				if(val<1 && le>0 && $("#level"+(le-1)).val() >0){
					$(".searchid").val($("#level"+(le-1)).val());
				}else{
					$(".searchid").val(val);
				}
				var ht='';
				var lev=le;
				if(val<1){
					lev=lev-1;
					if(lev<1){
						$('#address').html("");
						$('#street1').val("");
					}
				}
				for(var i=1;i<=lev;i++){
						ht=ht+$("#level"+i).find("option:selected").text();
						$('#address').html(ht);
						$('#street1').val(ht);
				}
				if($(obj).val()<1){
					$('#level'+(le+1)).remove();
					$('#level'+(le+2)).remove();
					$('#level'+(le+3)).remove();
					return ;
				}
				$.getJSON('home.php?m=addr&f=ajax&id='+$(obj).val()+'&tm='+Math.random(),'',function(data){
					if(data.status==true){
						$('#level'+(le+1)).remove();
						$('#level'+(le+2)).remove();
						$('#level'+(le+3)).remove();
						$(data.data).insertAfter($('#level'+le));
					}else{
					}
					});
			}
			</script>
		{/if}
{template footer}